<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
      <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <style>
        .radio-inline input[type=radio] {
            margin-top: 0px
        }

        .colorRed {
            color: red;
        }

        .bqName {
            padding: 2px 4px;
            border-radius: 6px;
            background: #d0e0e0;
            cursor: pointer;
        }
    </style>

</head>

<body class="white-bg" style="color:#333;padding:3px;">
 <div class="page-heade">
       <h2 class="title_color text-center">添加网点</h2>
    </div>
<div class="row white-bg setRemindPeopleK" style="margin:10px">
    <form action="" class="form-inline" id="add" method="post">
        <input type="hidden" name="system_id" value="{$id}">
        <table class="table table-bordered">
            <tr class="info">
                <th colspan="6">网点基本信息</th>
            </tr>
            <tr>
                <td><label for="" style="min-width: 160px;width: 160px">网点名称<span class="colorRed">*</span>：</label>
                </td>
                <td colspan="3"><input name="title" value="{:isset($data)?$data.title:''}" type="text"
                                       class="form-control" style="min-width: 200px;width: 200px"><span
                        class="colorRed">不允许英文状态下输入的单引号!</span></td>
                <td>所属系统名称</td>
                <td>{$sys.title}</td>
            </tr>
            <tr>
                <td><label for="" style="min-width: 160px;width: 160px">网点编号：</label></td>
                <td colspan="5"><input name="sn" value="{:isset($data)?$data.sn:''}" type="text" class="form-control"
                                       style="min-width: 160px;width: 160px"><span
                        class="colorRed">(温馨说明：如不填写网点编号，系统将自动分配一个编号。)</span></td>
            </tr>
            <tr>
                <td>
                    <label for="cat" style="min-width: 160px;width: 160px">网点类型<span class="colorRed">*</span>：</label>
                </td>
                <td>
                    <select name="cat" value="{:isset($data)?$data.cat:''}" id="cat"
                            style="min-width: 120px;width: 120px" class="form-control">
                        <option value="">请选择</option>
                        {volist name="cat" id="row"}
                        <option value="{$row.id}" {if isset($data)&&$row.id==$data.cat}selected{/if}>{$row.title}
                        </option>
                        {/volist}
                    </select>
                </td>
                <td>
                    <label for="" style="min-width: 160px;width: 160px">网点等级<span class="colorRed">*</span>：</label>
                </td>
                <td>
                    <select name="grade" value="{:isset($data)?$data.grade:''}" id="grade"
                            style="min-width: 120px;width: 120px" class="form-control">
                        <option value="">请选择</option>
                        {volist name="grade" id="row"}
                        <option value="{$row.id}" {if isset($data)&&$row.id==$data.grade}selected{/if}>{$row.title}
                        </option>
                        {/volist}
                    </select>
                </td>
                <td><label for="em_num" style="min-width: 160px;width: 160px">雇员人数(个)</label></td>
                <td><input id="em_num" name="em_num" value="{:isset($data)?$data.em_num:''}" type="text"
                           class="form-control"></td>
            </tr>
            <tr>
                <td><label for="area" style="min-width: 160px;width: 160px">店面面积(平方米):</label></td>
                <td><input id="area" name="area" value="{:isset($data)?$data.area:''}" type="text" class="form-control">
                </td>
                <td><label for="layers" style="min-width: 160px;width: 160px">店面层数:</label></td>
                <td><input id="layers" name="layers" value="{:isset($data)?$data.area:''}" type="text"
                           class="form-control"></td>
                <td><label for="abbr" style="min-width: 160px;width: 160px">网点简称:</label></td>
                <td><input id="abbr" name="abbr" value="{:isset($data)?$data.abbr:''}" type="text" class="form-control">
                </td>
            </tr>
            <tr>
                <td><label for="shelf_num" style="min-width: 160px;width: 160px">同品类货架节数(各产品):</label></td>
                <td><input id="shelf_num" name="shelf_num" value="{:isset($data)?$data.shelf_num:''}" type="text"
                           class="form-control"></td>
                <td><label for="cashiers" style="min-width: 160px;width: 160px">收银台数:</label></td>
                <td><input id="cashiers" name="cashiers" value="{:isset($data)?$data.cashiers:''}" type="text"
                           class="form-control"></td>
                <td><label for="area_same_cat" style="min-width: 160px;width: 160px">同品类面积:</label></td>
                <td><input id="area_same_cat" name="area_same_cat" value="{:isset($data)?$data.area_same_cat:''}"
                           type="text" class="form-control"></td>
            </tr>
            <tr>
                <td><label for="lanpushs_same_cat" style="min-width: 160px;width: 160px">同品类地堆数</label></td>
                <td><input id="lanpushs_same_cat" name="lanpushs_same_cat"
                           value="{:isset($data)?$data.lanpushs_same_cat:''}" type="text" class="form-control"></td>
                <td><label for="frames_same_cat" style="min-width: 160px;width: 160px">同品类端架数:</label></td>
                <td><input id="frames_same_cat" name="frames_same_cat" value="{:isset($data)?$data.frames_same_cat:''}"
                           type="text" class="form-control"></td>
                <td><label for="zipcode" style="min-width: 160px;width: 160px">邮编:</label></td>
                <td><input id="zipcode" name="zipcode" value="{:isset($data)?$data.zipcode:''}" type="text"
                           class="form-control"></td>
            </tr>
            <tr>
                <td><label for="" style="min-width: 160px;width: 160px">是否重点网点</label></td>
                <td>
                    <label class="radio-inline">
                        <input type="radio" name="iskey" id="inlineRadio1" value="1" {if
                               isset($data)&&$data.iskey==1}checked{/if}>是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="iskey" id="inlineRadio2" value="0" {if
                               !isset($data)||$data.iskey==0}checked{/if}>否
                    </label>
                </td>
                <td><label for="" style="min-width: 160px;width: 160px">是否直营网点:</label></td>
                <td>
                    <label class="radio-inline">
                        <input type="radio" name="direct" id="inlineRadio3" value="1" {if
                               isset($data)&&$data.direct==1}checked{/if}>是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="direct" id="inlineRadio4" value="0" {if
                               !isset($data)||$data.direct==0}checked{/if}>否
                    </label>
                </td>
                <td><label for="" style="min-width: 160px;width: 160px">是否导购网点:</label></td>
                <td>
                    <label class="radio-inline">
                        <input type="radio" name="guide" id="inlineRadio5" value="1" {if
                               isset($data)&&$data.guide==1}checked{/if}>是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="guide" id="inlineRadio6" value="0" {if
                               !isset($data)||$data.guide==0}checked{/if}>否
                    </label>
                </td>
            </tr>
            <tr>
                <td><label for="" style="min-width: 160px;width: 160px">一级渠道类型</label></td>
                <td>{$channel1}</td>
                <td><label for="" style="min-width: 160px;width: 160px">二级渠道类型</label></td>
                <td>{$channel2}</td>
                <td><label for="" style="min-width: 160px;width: 160px">开始合作日期</label></td>
                <td>
                    <div class="form-group">
                        <input name="cooptime" onclick="laydate()" value="{:isset($data)?$data.cooptime:''}" type="text"
                               id="start" placeholder="开始日期" class="form-control layer-date "
                               style="height: 26px;display: inline-block;">
                    </div>
                </td>
            </tr>
            <tr>
                <td><label for="myarea" style="min-width: 160px;width: 160px">系统自编区域:</label></td>
                <td><input id="myarea" name="myarea" value="{:isset($data)?$data.myarea:''}" type="text"
                           class="form-control"></td>
                <td><label for="mysn" style="min-width: 160px;width: 160px">系统自编店号:</label></td>
                <td><input id="mysn" name="mysn" value="{:isset($data)?$data.mysn:''}" type="text" class="form-control">
                </td>
                <td><label for="mypart" style="min-width: 160px;width: 160px">系统自编分仓:</label></td>
                <td><input id="mypart" name="mypart" value="{:isset($data)?$data.mypart:''}" type="text"
                           class="form-control"></td>
            </tr>
            <tr>
                <td><label for="mypart_code" style="min-width: 160px;width: 160px">系统自编分仓代码:</label></td>
                <td><input id="mypart_code" name="mypart_code" value="{:isset($data)?$data.mypart_code:''}" type="text"
                           class="form-control"></td>
                <td><label for="starttime" style="min-width: 160px;width: 160px">网店开店日期:</label></td>
                <td><input id="starttime" onclick="laydate()" name="starttime"
                           value="{:isset($data)?$data.starttime:''}" type="text" class="form-control"></td>
                <td><label for="" style="min-width: 160px;width: 160px">是否样板网点:</label></td>
                <td>
                    <label class="radio-inline">
                        <input type="radio" name="sample" id="inlineRadio7" value="1" {if
                               isset($data)&&$data.sample==1}checked{/if}>是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="sample" id="inlineRadio8" value="0" {if
                               !isset($data)||$data.sample==0}checked{/if}>否
                    </label>
                </td>
            </tr>
            <tr>
                <td><label for="" style="min-width: 160px;width: 160px">是新进网点:</label></td>
                <td colspan="5">
                    <label class="radio-inline">
                        <input type="radio" name="isnew" id="inlineRadio71" value="1" {if
                               isset($data)&&$data.isnew==1}checked{/if}>是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="isnew" id="inlineRadio81" value="0" {if
                               !isset($data)||$data.isnew==0}checked{/if}>否
                    </label>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="" style="min-width: 160px;width: 160px">网点所属营销区域<span class="colorRed">*</span>：</label>
                </td>
                <td colspan="5">
                    <span>城市：</span>
                    <select name="zoning" id="zoning" style="min-width: 120px;width: 120px" class="form-control">
                        <option value="">请选择分区</option>
                        {volist name="zoning" id="row"}
                        <option value="{$row.id}" {if isset($data)&&$row.id==$data.zoning}selected{/if}>{$row.title}
                        </option>
                        {/volist}
                    </select>
                    <select name="provice" id="provice" style="min-width: 120px;width: 120px" class="form-control">
                        <option value="">请选择省份</option>
                    </select>
                    <select name="city" id="city" style="min-width: 120px;width: 120px" class="form-control">
                        <option value="">请选择城市</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="" style="min-width: 160px;width: 160px">网点所属行政区域：</label>
                </td>
                <td colspan="5">
                    省份：
                    <select name="exec_provice" id="exec_provice" style="min-width: 120px;width: 120px"
                            class="form-control">
                        <option value="">请选择省份</option>
                        {volist name="exec_provice" id="row"}
                        <option value="{$row.id}" {if isset($data)&&$row.id==$data.exec_provice}selected{/if}>
                            {$row.title}
                        </option>
                        {/volist}
                    </select>
                    城市：
                    <select name="exec_city" id="exec_city" style="min-width: 120px;width: 120px" class="form-control">
                        <option value="">请选择城市</option>
                    </select>
                    区县：
                    <select name="exec_county" id="exec_county" style="min-width: 120px;width: 120px"
                            class="form-control">
                        <option value="">请选择区县</option>
                    </select>
                    <label for="detailAddress">详细地址<span class="colorRed">*</span></label>
                    <input id="detailAddress" name="detailAddress" value="{:isset($data)?$data.detailAddress:''}"
                           type="text" class="form-control" style="width: 240px;min-width: 240px">
                </td>
            </tr>
            <tr>
                <td rowspan="2" style="min-width: 160px;width: 160px">备注：</td>
                <td rowspan="2" colspan="5">
                    <textarea name="brief" id="brief" style="width: 60%;line-height: 60px; resize: none;" class="form-control">{:isset($data)?$data.brief:''}</textarea><span style="vertical-align: bottom;">(500)</span>
                </td>
            </tr>
        </table>
        <table class="table table-bordered">
            <tr class="info">
                <th colspan="2">网点所属系统信息</th>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px">系统名称：</td>
                <td><a href="javascript:;">{$system_info.title}</a></td>
            </tr>
            <tr>
                <td>业务人员</td>
                <td>{$system_info.stuff}</td>
            </tr>
        </table>
        <table class="table table-bordered">
            <tr class="info">
                <th colspan="6">网点所属经销商信息</th>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px">所属经销商：</td>
                <td colspan="2"><a href="javascript:;">{$jxs.title}</a></td>
                <td style="min-width: 160px;width: 160px">经销商编码：</td>
                <td colspan="2"><a href="javascript:;">{$jxs.sn}</a></td>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px">分区负责人：</td>
                <td><a href="javascript:;">{$jxs.zoning_head}</a></td>
                <td style="min-width: 160px;width: 160px">省份负责人：</td>
                <td><a href="javascript:;">{$jxs.provice_head}</a></td>
                <td style="min-width: 160px;width: 160px">城市负责人：</td>
                <td><a href="javascript:;">{$jxs.city_head}</a></td>
            </tr>
            <tr>
                <td style="min-width: 160px;width: 160px">网点所属经销商所在的营销区域：</td>
                <td colspan="5">{$jxs.market}</td>
            </tr>
        </table>
        <table class="table table-bordered">
            <tr class="info">
                <th colspan="2">网点负责人：</th>
            </tr>
            <tr>
                <td class="text-center">业务人员</td>
                <td>
                    <div class="col-xs-2">
                        <div class="input-group">
                            <input name="stuff" id="testNoBtn" type="text" placeholder="请输入关键字或空格查询"
                                   class="input12 form-control" value="">
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                            <div class="renyuan" id="renyuan" style="top:32px">
                                {if isset($data)}
                                {volist name="data.stuff" id="row"}
                                <span class="ren" data-id="{$row.id}">{$row.em_name}<span class="close"></span></span>
                                {/volist}
                                {/if}
                            </div>
                        </div>

                    </div>
                    <div class="col-xs-8">
                        <a href="javascript:;" id="select" class="btn btn-default btn-outline">选择</a>
                    </div>
                </td>
            </tr>
            <tr>
                <td></td>
                <td></td>
            </tr>
        </table>
        <table class="table-bordered table text-center">
            <tr class="info">
                <td>网点联络信息<span class="colorRed">(至少填一条)</span></td>
                <td colspan="6"></td>
            </tr>
            <tr class="info">
                <td>联系人姓名<span class="colorRed">*</span></td>
                <td>联系电话<span class="colorRed">*</span></td>
                <td>手机<span class="colorRed">*</span></td>
                <td>传真</td>
                <td>电子邮件</td>
                <td>职务</td>
                <td>
                    <button class="btn btn-success addManInfo">添加</button>
                </td>
            </tr>
            <tr>
                <td><input type="text" class="form-control input1" style="width: 100px;min-width: 100px"
                           name="systemContact[name][]"></td>
                <td><input type="text" class="form-control input2" style="width: 50px;min-width: 50px"
                           name="systemContact[phone1][]">-<input type="text" class="form-control input22"
                                                                  style="width: 100px;min-width: 100px"
                                                                  name="systemContact[phone2][]"></td>
                <td><input type="text" class="form-control input21" name="systemContact[mobile][]"
                           style="width: 120px;min-width: 120px"></td>
                <td><input type="text" class="form-control input2" style="width: 50px;min-width: 50px"
                           name="systemContact[fax1][]">-<input type="text" class="form-control input22"
                                                                style="width: 100px;min-width: 100px"
                                                                name="systemContact[fax2][]"></td>
                <td><input type="text" class="form-control input21" name="systemContact[email][]"
                           style="width: 120px;min-width: 120px"></td>
                <td><input type="text" class="form-control input21" name="systemContact[job][]"></td>
                <td>&nbsp;</td>
            </tr>

        </table>
        <table class="table table-bordered">
            <tr>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">收货地址1 <span class="colorRed">*</span>:</label>
                </td>
                <td><input name="lgs_rcv_addr" type="text" class="form-control" style="width: 200px;min-width: 200px">
                </td>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">收货人1 <span class="colorRed">*</span>:</label>
                </td>
                <td><input name="lgs_rcv_one" type="text" class="form-control"></td>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">联系电话1 <span class="colorRed">*</span>:</label>
                </td>
                <td><input name="lgs_rcv_phone" type="text" class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">收货地址2:</label></td>
                <td><input name="lgs_rcv_addr2" type="text" class="form-control" name=""
                           style="width: 200px;min-width: 200px"></td>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">收货人2:</label></td>
                <td><input name="lgs_rcv_one2" type="text" class="form-control"></td>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">联系电话2:</label></td>
                <td><input name="lgs_rcv_phone2" type="text" class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">收货地址3:</label></td>
                <td><input name="lgs_rcv_addr3" type="text" class="form-control" style="width: 200px;min-width: 200px">
                </td>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">收货人3:</label></td>
                <td><input name="lgs_rcv_one3" type="text" class="form-control"></td>
                <td class="text-right"><label for="" style="min-width: 160px;width: 160px">联系电话3:</label></td>
                <td><input name="lgs_rcv_phone3" type="text" class="form-control"></td>
            </tr>
        </table>

        <table class="table">
            <tr class="info">
                <th>网点已进场条码管理(如果没哟可不填)</th>
            </tr>
            <tr class="font-bold">
                <td>温馨提醒:</td>
            </tr>
            <tr>
                <td>1.已进场条码在这里补录</td>
            </tr>
            <tr>
                <td>2.已进场条码不允许重复进场，如需进场请先退场再进场</td>
            </tr>
            <tr>
                <td>3.新增网点产品未有进场不需要维护条码，要打进场申请，进场申请生效后本次进场条码会自动录入到这里的已进场条码中。</td>
            </tr>
        </table>

        <table class="table table-bordered text-center da_table">
            <thead>
            <tr class="info">
                <th class="text-center">产品</th>
                <th class="text-center">进场时间</th>
                <th class="text-center">进场费(元)</th>
                <th class="text-center">卖场零售价(元)</th>
                <th class="text-center"><a class="btn btn-success addNetToAngency" type="button">添加</a></th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>
                    <span class="changeThis">
                        <div style="display: inline-block;margin-top: 10px;margin-bottom: 9px;">
                            <div class="input-group">
                                <input type="text" placeholder="请输入关键字或空格查询" class="testNoBtn2 input12 form-control"
                                       value="">
                                <div class="input-group-btn">
                                    <button type="button" class="btn btn-default dropdown-toggle"
                                            data-toggle="dropdown">
                                        <span class="caret"></span></button>
                                    <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
                                </div>
                            </div>
                        </div>
                        <a href="javascript:;" class="changeThisA btn btn-outline btn-default select2">选择</a>
                    </span><input type="hidden" name="barcode[prod][]" value="">
                </td>
                <td>
                    <div class="form-group">
                        <input type="text" name="barcode[intime][]" onclick="laydate();"
                               class="dataTime form-control layer-date" style="height: 22px;display: inline-block;">
                    </div>
                </td>
                <td><input type="text" name="barcode[infee][]" class="form-control"></td>
                <td><input type="text" name="barcode[retailPrice][]" class="form-control"></td>
                <td>&nbsp;</td>
            </tr>
            </tbody>
        </table>

        <table class="table-bordered table text-center" id="comp_table">
            <tr class="info">
                <td colspan="6" class="text-left">竞品管理(如果没有可不填)</td>
            </tr>
            <tr class="info">
                <td>竞品品类</td>
                <td>竞品名称</td>
                <td>零售价(元)</td>
                <td>竞品规格</td>
                <td>竞品描述</td>
                <td><a href="javascript:;" rol="button" class="btn btn-success" id="addCompetitor">添加</a></td>
            </tr>
            <tr>
                <td>
                    <select name="com[cate][]" class="com_cate form-control select">
                        <option value="">请选择</option>
                        {volist name="com_cate" id="row"}
                        <option value="{$row.id}">{$row.category_name}</option>
                        {/volist}
                    </select>
                </td>
                <td>
                    <select name="com[id][]" class="competitor form-control select">
                        <option value="">请选择</option>
                    </select>
                </td>
                <td>
                    <input name="com[price][]" type="text" class="form-control">
                </td>
                <td>
                    <input name="com[specs][]" type="text" class="form-control">
                </td>
                <td>
                    <input name="com[brief][]" type="text" class="form-control" style="min-width: 240px;width: 240px">
                </td>
                <td><a href="javascript:;" class="btn-danger btn delCompetitor">删除</a></td>
            </tr>
        </table>

        <div class="col-md-12 border_S">
            <span class="colorRed">附件</span>
        </div>
        <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list"></div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach">
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
        <div class="col-md-12 text-center" style="padding: 10px 0">
            <button class="btn-success btn" id="tijiao">确认并提交</button>
            <button class="btn-info btn" id="confirmAndMore">确认并再添加一条</button>
            <button class="btn-warning btn" id="cancelBack">返回</button>
        </div>

    </form>
</div>

<!-- 全局js -->
{include file="Public/footer"}
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script>
    $(function () {

        //已进场条码管理
        $('body').on('click','.select2',function(){
            var _this = this
            layer.open({
                type:2,
                title:'修改',
                area:['95%','80%'],
                content:'{:url("open/product3")}',
                btn:['确定','关闭'],
                yes:function (i,o) {
                    var a = $(o).find('iframe').contents()

                    var id =  a.find("#renyuan").val();
                    var name =  a.find("#renyuanname").val();
                    var unit =  a.find("#unit").val();
                    var pro_no =  a.find("#pro_no").val();
                    var fayun_price =  a.find("#lingshou_price").val();
                    if(id){
                        $(_this).closest('td').html('<span class="bqName" data-id="' + id + '">' + name+ '<span class="delBqName">×</span></span><input type="hidden" name="barcode[prod][]" value="' + id + '">')

                    }

                    layer.close(i)
                }
            })
        })

        $('#addCompetitor').on('click', function () {
            $('#comp_table').append('<tr>\n' +
                '                <td>\n' +
                '                    <select name="com[cate][]" class="com_cate">\n' +
                '                        <option value="">请选择</option>\n' +
                '                        {volist name="com_cate" id="row"}\n' +
                '                        <option value="{$row.id}">{$row.category_name}</option>\n' +
                '                        {/volist}\n' +
                '                    </select>\n' +
                '                </td>\n' +
                '                <td>\n' +
                '                    <select name="com[id][]" class="competitor">\n' +
                '                        <option value="">请选择</option>\n' +
                '                    </select>\n' +
                '                </td>\n' +
                '                <td>\n' +
                '                    <input name="com[price][]" type="text" class="form-control">\n' +
                '                </td>\n' +
                '                <td>\n' +
                '                    <input name="com[specs][]" type="text" class="form-control">\n' +
                '                </td>\n' +
                '                <td>\n' +
                '                    <input name="com[brief][]" type="text" class="form-control" style="min-width: 240px;width: 240px">\n' +
                '                </td>\n' +
                '                <td><a href="javascript:;" class="btn-danger btn delCompetitor">删除</a></td>\n' +
                '            </tr>');
        })
        $('body').on('click', '.delCompetitor', function () {
            $(this).closest('tr').remove()
        })
    })
</script>
<script>
    $(document).ready(function () {

        $('body').on('change', '.com_cate', function () {
            var id = $(this).val()
            $(this).closest('td').next('td').find('.competitor').load('{:url("select/competitor")}?catid=' + id)
        })
        $('body').on('change', '.competitor', function () {
            var _this = this;
            var id = $(this).val()
            $.get('{:url("format")}?id=' + id, function (data) {
                $(_this).closest('td').next('td').next('td').find('input').val(data);
            })
        })
        $('#zoning').on('change', function () {
            var id = $(this).val()
            $('#provice').load('{:url("select/provice")}?id=' + id)
        })

        $('#provice').on('change', function () {
            var id = $(this).val()
            $('#city').load('{:url("select/city")}?id=' + id)
        })
        $('#exec_provice').on('change', function () {
            var id = $(this).val()
            $('#exec_city').load('{:url("select/ecity")}?id=' + id)
        })
        $('#exec_city').on('change', function () {
            var id = $(this).val()
            $('#exec_county').load('{:url("select/ecounty")}?id=' + id)
        })


        // 添加系统联系人信息
        $(".addManInfo").on("click", function () {
            var str = '<tr><td><input type="text" class="form-control input1" style="width: 100px;min-width: 100px" name="systemContact[name][]"></td><td><input type="text" class="form-control input2" style="width: 50px;min-width: 50px" name="systemContact[phone1][]">-<input type="text" class="form-control input22" style="width: 100px;min-width: 100px" name="systemContact[phone2][]"></td><td><input type="text" class="form-control input21" name="systemContact[mobile][]" style="width: 120px;min-width: 120px"></td><td><input type="text" class="form-control input2" style="width: 50px;min-width: 50px" name="systemContact[fax1][]">-<input type="text" class="form-control input22" style="width: 100px;min-width: 100px" name="systemContact[fax2][]"></td><td><input type="text" class="form-control input21"  name="systemContact[email][]" style="width: 120px;min-width: 120px"></td><td><input type="text" class="form-control input21"  name="systemContact[job][]"></td><td><button class="btn btn-danger delthis">删除</button></td></tr>'
            $(this).closest("table").append(str);

            return false
        })

        $(document).on("click", ".delthis", function () {
            $(this).parent().parent().remove();
            return false
        })

        //添加网点已进场条码
        $(".addNetToAngency").click(function () {
            var str = '<tr>\n' +
                '                <td>\n' +
                '                    <span class="changeThis">\n' +
                '                        <div style="display: inline-block;margin-top: 10px;margin-bottom: 9px;">\n' +
                '                            <div class="input-group">\n' +
                '                                <input type="text" placeholder="请输入关键字或空格查询" class="testNoBtn2 input12 form-control" value="">\n' +
                '                                <div class="input-group-btn">\n' +
                '                                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">\n' +
                '                                        <span class="caret"></span></button>\n' +
                '                                    <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>\n' +
                '                                </div>\n' +
                '                            </div>\n' +
                '                        </div>\n' +
                '                        <a href="javascript:;" class="changeThisA btn btn-outline btn-default select2">选择</a>\n' +
                '                    </span><input type="hidden" name="barcode[prod][]" value="">\n' +
                '                </td>\n' +
                '                <td>\n' +
                '                    <div class="form-group">\n' +
                '                        <input type="text" name="barcode[intime][]" onclick="laydate();" class="dataTime form-control layer-date" style="height: 26px;display: inline-block;">\n' +
                '                    </div>\n' +
                '                </td>\n' +
                '                <td><input type="text" name="barcode[infee][]" class="form-control"></td>\n' +
                '                <td><input type="text" name="barcode[retailPrice][]" class="form-control"></td>\n' +
                '                <td>&nbsp;</td>\n' +
                '            </tr>'
            $(".da_table tbody").append(str);

            var _o = $(this).closest("table").find('tr').last()
            _o.find(".testNoBtn2").bsSuggest({
                url: "{:url('productjson')}",
                /*effectiveFields: ["userName", "shortAccount"],
                searchFields: [ "shortAccount"],*/
                effectiveFieldsAlias: {userName: "姓名"},
                ignorecase: true,
                showHeader: true,
                showBtn: false,     //不显示下拉按钮
                delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
                idField: "id",
                keyField: "title",
                clearable: true
            }).on('onDataRequestSuccess', function (e, result) {
                console.log('onDataRequestSuccess: ', result);
            }).on('onSetSelectValue', function (e, keyword, data) {
                var testNoBtn = $(this).closest('td')
                testNoBtn.html('<span class="bqName" data-id="' + keyword.id + '">' + keyword.key + '<span class="delBqName">×</span></span><input type="hidden" name="barcode[prod][]" value="' + keyword.id + '">')

            }).on('onUnsetSelectValue', function () {
                console.log("onUnsetSelectValue");
            });

            return false
        })

        $(".da_table").on("click", ".delThisTr", function () {

            $(this).parent().parent().remove();

        })

    })

    $(".testNoBtn2").bsSuggest({
        url: "{:url('productjson')}",
        /*effectiveFields: ["userName", "shortAccount"],
        searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias: {userName: "姓名"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onDataRequestSuccess', function (e, result) {
        console.log('onDataRequestSuccess: ', result);
    }).on('onSetSelectValue', function (e, keyword, data) {
        var testNoBtn = $(this).closest('td')
        testNoBtn.html('<span class="bqName" data-id="' + keyword.id + '">' + keyword.key + '<span class="delBqName">×</span></span><input type="hidden" name="barcode[prod][]" value="' + keyword.id + '">')

    }).on('onUnsetSelectValue', function () {
        console.log("onUnsetSelectValue");
    });

    //取消选择产品
    $("body").on('click', '.delBqName', function () {
        var _o = $(this).closest('td')
        var str = '<span class="changeThis">\n' +
            '                <div style="display: inline-block;margin-top: 10px;margin-bottom: 9px;">\n' +
            '                        <div class="input-group">\n' +
            '                            <input type="text" placeholder="请输入关键字或空格查询" class="testNoBtn2 input12 form-control" value="">\n' +
            '                            <div class="input-group-btn">\n' +
            '                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">\n' +
            '                                    <span class="caret"></span>\n' +
            '                                </button>\n' +
            '                                <ul class="dropdown-menu dropdown-menu-right" role="menu">\n' +
            '                                </ul>\n' +
            '                            </div>\n' +
            '                        </div>\n' +
            '                    </div>\n' +
            '                <a href="javascript:;" class="changeThisA btn btn-outline btn-default select2">选择</a>\n' +
            '            </span><input type="hidden" name="barcode[prod][]" value="">'
        $(this).parent().parent().html(str)


        _o.find(".testNoBtn2").bsSuggest({
            url: "{:url('productjson')}",
            /*effectiveFields: ["userName", "shortAccount"],
            searchFields: [ "shortAccount"],*/
            effectiveFieldsAlias: {userName: "姓名"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "title",
            clearable: true
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
            var testNoBtn = $(this).closest('td')
            testNoBtn.html('<span class="bqName" data-id="' + keyword.id + '">' + keyword.key + '<span class="delBqName">×</span></span><input type="hidden" name="barcode[prod][]" value="' + keyword.id + '">')
        }).on('onUnsetSelectValue', function () {
            console.log("onUnsetSelectValue");
        });

        return false

    })

</script>
<script>
    var cancelBack = document.getElementById('cancelBack')
    cancelBack.onclick = function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    /**
     * touxingren (首次从 URL 获取数据，显示 header，不显示按钮，忽略大小写，可清除)
     */
    $("#testNoBtn").bsSuggest({
        url: "{:url('jxsgl/provicejson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias: {userName: "姓名"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onDataRequestSuccess', function (e, result) {
        console.log('onDataRequestSuccess: ', result);
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).val('')
        var bool = false
        $('#renyuan .ren').each(function (idx, o) {
            if ($(this).data('id') == keyword.id) {
                bool = true;
            }
        })
        if (bool == false)
            $('#renyuan').append('<span class="ren" data-id="' + keyword.id + '">' + keyword.key + '<span class="close">×</span></span>')
        //console.log('onSetSelectValue: ', keyword, data);
    }).on('onUnsetSelectValue', function () {
        console.log("onUnsetSelectValue");
    });

    //弹窗选择提醒人
    $('#select').on('click', function () {
        var index = layer.getFrameIndex(window.name)
        //iframe层-父子操作
        layer.open({
            type: 2,
            title: '请选择提醒人员',
            area: ['500px', '400px'],
            fixed: false, //不固定
            maxmin: true,
            content: '{:url("jxsgl/selectsalesman")}?frameindex=' + index
        });
        return false
    })

    //提交
    $('#tijiao').on('click', function () {
        var form = $('#add')
        var serial = form.not($('input[name=stuff]')).serialize()

        var admin = []
        $('#renyuan .ren').each(function (idx, o) {
            admin.push($(o).data('id'))
        })
        var admin2 = ''
        if (admin)
            admin2 = admin.join(',')

        serial = serial + '&stuff=' + admin2
        console.log(serial)
        $.ajax({
            'type': 'post',
            'url': form.attr('action'),
            'data': serial,
            'dataType': 'json',
            'success': function (data) {
                if (data.success) {
                    swal({
                        title: data.msg,
                        type: "success"
                    }, function () {
                        parent.layer.close(parent.layer.getFrameIndex(window.name))
                    });

                } else
                    swal({
                        title: data.msg,
                        type: "warning"
                    });
            }
        })
        return false
    })
    //提交
    $('#confirmAndMore').on('click', function () {
        var form = $('#add')
        var serial = form.not($('input[name=stuff]')).serialize()

        var admin = []
        $('#renyuan .ren').each(function (idx, o) {
            admin.push($(o).data('id'))
        })
        var admin2 = ''
        if (admin)
            admin2 = admin.join(',')

        serial = serial + '&stuff=' + admin2
        console.log(serial)
        $.ajax({
            'type': 'post',
            'url': form.attr('action'),
            'data': serial,
            'dataType': 'json',
            'success': function (data) {
                if (data.success) {
                    swal({
                        title: data.msg,
                        type: "success"
                    }, function () {
                        location.reload()
                    });

                } else
                    swal({
                        title: data.msg,
                        type: "warning"
                    });
            }
        })
        return false
    })

</script>

<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script>
    // 文件上传
    jQuery(function () {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on('fileQueued', function (file) {
            $list.append('<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>');
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on('uploadProgress', function (file, percentage) {
            var $li = $('#' + file.id),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if (!$percent.length) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo($li).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css('width', percentage * 100 + '%');
        });

        uploader.on('uploadSuccess', function (file, response) {
            if (response.success)
                ids.push(response.id)
            $('#' + file.id).find('p.state').text(response.msg);
        });

        uploader.on('uploadError', function (file) {
            $('#' + file.id).find('p.state').text('上传出错');
        });

        uploader.on('uploadComplete', function (file) {
            $('#attach').val(ids.join(','))
            $('#' + file.id).find('.progress').fadeOut();
        });

        uploader.on('all', function (type) {
            if (type === 'startUpload') {
                state = 'uploading';
            } else if (type === 'stopUpload') {
                state = 'paused';
            } else if (type === 'uploadFinished') {
                state = 'done';
            }

            if (state === 'uploading') {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on('click', function () {
            if (state === 'uploading') {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

        $('#renyuan').on('click', '.ren .close', function () {
            $(this).closest('.ren').remove()
        })
    });
</script>
</body>

</html>